package com.cfm880.latte;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Toast;

import com.cfm880.latte.core.delegates.LatteDelegate;
import com.cfm880.latte.core.net.RestClient;
import com.cfm880.latte.core.net.callback.IError;
import com.cfm880.latte.core.net.callback.IFailure;
import com.cfm880.latte.core.net.callback.ISuccess;

/**
 * Created by chengfangming on 2018/1/6.
 */

public class ExampleDelegate extends LatteDelegate {
    @Override
    public Object setLayout() {
        return R.layout.delegate_exmaple;
    }

    @Override
    public void onBindView(@Nullable Bundle saveInstanceState, View rootView) {
        System.out.println("呵呵哈哈哈");
        RestClient.builder().url("http://www.baidu.com")
                .loader(getContext())
                .success(new ISuccess() {
                    @Override
                    public void onSuccess(String response) {
                        Toast.makeText(getContext(), response, Toast.LENGTH_SHORT).show();
                    }
                }).failure(new IFailure() {
                    @Override
                    public void onFailure() {

                    }
                }).error(new IError() {
                    @Override
                    public void onError(int code, String msg) {

                    }
                }).build()
                .get();
    }
}
